package org.baygo.view.api.listener;

import org.baygo.view.MainFrame;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class CreateNewConnectButtonActionListener implements ActionListener{
	private Logger log = LoggerFactory.getLogger(CreateNewConnectButtonActionListener.class);

	private Component comp;

	public CreateNewConnectButtonActionListener(Component comp){
		this.comp = comp;
	}

	public void actionPerformed(ActionEvent e) {
		String ipAndPort = JOptionPane.showInputDialog(comp, new JLabel("请按如下格式输入IP地址和端口号:"), "127.0.0.1 9981");
		if (ipAndPort!=null && ipAndPort.trim().length()>0){
			MainFrame.getPanel().openNewConnectButton(ipAndPort, true);
		}
	}
	
}